package router

import (
	"Short_chain_cats/middleware"
	"Short_chain_cats/shortlink/controller"

	"github.com/gin-gonic/gin"
)

func RegisterShortLinkRoute(v1 *gin.RouterGroup) {

	linksCtrl := controller.LinksController
	{
		v1.GET("/:shortLink", linksCtrl.Visit) //通过短链查找长链
	}

	v1.Use(middleware.JWTAuth())
	v1.Use(middleware.CasbinMiddleware())
	v1.Use(middleware.SecurityMiddleware())
	{
		v1.POST("/links/generate", linksCtrl.Generate) //生成短链
		v1.GET("/links/view", linksCtrl.View)          //查看所有短链

		v1.PUT("/links/publish", linksCtrl.Publish)           //发布短链
		v1.DELETE("/links/remove/:linksId", linksCtrl.Remove) //删除短链
		v1.POST("/links/Restore", linksCtrl.Restore)          //还原短链
		v1.PUT("/links/edit", linksCtrl.Edit)                 //修改短链信息
	}

	tagsCtl := controller.TagsController
	{
		v1.GET("/tags/search", tagsCtl.Search) //查看所有的标签
		v1.POST("/tags/add", tagsCtl.Add)      //添加标签
	}
}
